<template>
	<view class="content">
		<!-- <div style="position: fixed;  top: 180rpx; left: 35rpx; display: flex; justify-content: space-between;" >
			<div @click="goDq">当前位置：<span style="color: blue;">{{cityName}}</span> </div> 
			<div style="margin-left: 100rpx;" @click="getCurrentCity"><uni-icons type="location" size="18"></uni-icons>重新获取定位</div>
		</div> -->
	
		<!-- 	<picker mode="region" :value="region" @change="bindTimeChange">
			<view class="picker" style="position: fixed; top: 180rpx; left: 35rpx;">
				地区选择：{{provinceName}}
			</view>
		</picker> -->
		<view class="login">
			<view class="login-info">
				<view class="info-name">
					{{userinfo.name== undefined?'暂未设置用户名':userinfo.name }}
				</view>
				<view class="info-text">
					欢迎回来~~~
				</view>
			</view>
			<view class="info-img">
				<image src="../../static/tabbar/mine_.png" class="w100h100 " mode=""></image>
			</view>
		</view>
		<view class="menu">
			<view class="menu-item" @click="toxiugai">
				<view class="item-icon">
					<u-icon name="order" size="28" color="#000"></u-icon>
				</view>
				<view class="item-text">
					个人信息
				</view>
				<view class="item-right">
					<u-icon name="arrow-right" size="20" color="#000"></u-icon>
				</view>
			</view>
			<view class="menu-item" @click="tomybaomings">
				<view class="item-icon">
					<u-icon name="order" size="28" color="#000"></u-icon>
				</view>
				<view class="item-text">
					我的报名
				</view>
				<view class="item-right">
					<u-icon name="arrow-right" size="20" color="#000"></u-icon>
				</view>
			</view>
			<view class="menu-item" @click="toabout(1)">
				<view class="item-icon">
					<u-icon name="order" size="28" color="#000"></u-icon>
				</view>
				<view class="item-text">
					关于我们
				</view>
				<view class="item-right">
					<u-icon name="arrow-right" size="20" color="#000"></u-icon>
				</view>
			</view>

			<!-- <view class="menu-item">
                <view class="item-icon">
                    <u-icon name="order" size="28" color="#000"></u-icon>
                </view>
                <view class="item-text">
                    退出登录
                </view>
                <view class="item-right">
                    <u-icon name="arrow-right" size="20" color="#000"></u-icon>
                </view>
            </view> -->
		</view>
	</view>
</template>

<script>
	import QQMapWX from '../../common/qqmap-wx-jssdk.js'
	export default {
		data() {
			return {
				QQMapWXKey:'M4GBZ-3ZE6T-5JJXA-VXCI3-NSXHS-EAB64',
				cityName: '',
				userinfo: {},
				provinceName: '12',
				region: ['010000', '010000'] // 默认选中北京市
			}
		},
		onShow() {

			this.userinfo = uni.getStorageSync('userInfo')
			console.log(this.userinfo);

		},
		onLoad() {
			// this.getCurrentCity();
		},
		methods: {
			setData(cityName) {
				console.log(cityName, 'cityNamecityName')
				this.cityName = cityName
			},
			goDq() {
				uni.navigateTo({
					url: `/pages/ciitys/cityList`
				})
			},
			getCurrentCity() {
				//获取城市
				let that = this
				// 实例化腾讯API核心类
				let qqmapsdk = new QQMapWX({
					key: this.QQMapWXKey
				});
			
					//如果本地没有存储就通过uni.getLocation获取当前位置的经纬度
					uni.getLocation({
						type: 'gcj02',
						success: function(res) {
							uni.setStorageSync('latitude', res.latitude)
							uni.setStorageSync('longitude', res.longitude)
							// 通过经纬度获取当前城市信息
							qqmapsdk.reverseGeocoder({
								location: {
									latitude: uni.getStorageSync('latitude'),
									longitude: uni.getStorageSync('longitude')
								},
								success: function(res1) {
									console.log(res1,'ress1s1s1s1s1s11s')
									that.cityName = res1.result.ad_info.city;
									uni.setStorageSync('city', res1.result.ad_info.city)
								},
								fail: function(res) {
									uni.showToast({
										title: res.message,
										icon: 'none'
									})
								}
							})
						},
						fail: function() {
							uni.showToast({
								title: "当前位置信息获取失败",
								icon: 'none'
							})
						}

					})
			
			},
			// 获取省市区
			bindTimeChange(e) {
				console.log(e, 'eeeeee456')
				this.province = e.detail.value[0];
				this.city = e.detail.value[1];
				this.provinceName = e.detail.value[0] + e.detail.value[1];
			},

			tomybaomings() {
				uni.navigateTo({
					url: `/packageA/pages/mybaoming/mybaoming`
				})
			},
			toxiugai() {
				uni.navigateTo({
					url: `/packageA/pages/xiugai/xiugai`
				})
			},
			toabout(val) {
				if (val == 1) {
					uni.navigateTo({
						url: `/packageA/pages/about/about`
					})
				} else {
					uni.navigateTo({
						url: `/packageA/pages/ziliao/ziliao`
					})
				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	.picker {
		padding: 10px;
		background-color: #fff;
		text-align: center;
	}

	.content {
		width: 100%;
		height: 100vh;
		background: url('http://qnimg.hdjincheng.com/bde6b049-5ba7-4703-ae3b-13aa44be3927.png') no-repeat;
		background-size: 100% 100%;
	}

	.login {
		padding: 20vh 40rpx 80rpx 40rpx;
		display: flex;
		justify-content: space-between;

		.login-info {
			display: flex;
			justify-content: center;
			align-items: flex-start;
			flex-direction: column;

			.info-name {
				font-size: 40rpx;
				// font-weight: 700;
				margin-bottom: 10rpx;
			}

			.info-text {
				font-size: 26rpx;
			}
		}

		.info-img {
			width: 100rpx;
			height: 100rpx;
		}
	}

	.menu {
		box-sizing: border-box;
		width: 710rpx;
		margin: 20rpx auto;
		padding: 20rpx;
		background-color: #f2f2f2;
		border-radius: 40rpx;
	}

	.menu-item {
		padding: 20rpx 20rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		border-bottom: 1px solid #ebebeb;

		.item-right {
			margin-left: auto;
		}

		.item-text {
			margin-left: 10rpx;
		}
	}
</style>